package com.itbaima.mapper;

import com.itbaima.pojo.entity.HrSalary;
import com.itbaima.pojo.entity.Salary;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface SalaryStandardMapper {

    // 使用 @Insert 注解插入数据
    @Insert("INSERT INTO salary_standard (salary_id,department_id, salary_standard_name, basic_salary, allowance, " +
            "pension_insurance, medical_insurance, unemployment_insurance, housing_fund, total_salary, creator_name, " +
            "registrar, registrar_id, registration_time) " +
            "VALUES (#{salary_id},#{departmentId}, #{salaryStandardName}, #{basicSalary}, #{allowance}, " +
            "#{pensionInsurance}, #{medicalInsurance}, #{unemploymentInsurance}, #{housingFund}, #{totalSalary}, " +
            "#{creatorName}, #{registrar}, #{registrarId}, #{registrationTime})")
    int insertSalary(Salary salary);


    @Update("UPDATE hrsalary " +
            "   SET salary_id = #{hrSalary.salary_id}, " +
            "    total_salary = #{hrSalary.total_salary}, " +
            "    allowance = #{hrSalary.allowance}, " +
            "    pension_insurance = #{hrSalary.pensionInsurance}, " +
            "    medical_insurance = #{hrSalary.medicalInsurance}, " +
            "    unemployment_insurance = #{hrSalary.unemploymentInsurance}, " +
            "    housing_fund = #{hrSalary.housing_fund}, " +
            "    bonus = #{hrSalary.bonus}, " +
            "    dock = #{hrSalary.dock} " +
            "WHERE id = #{hrSalary.id}")
    void update(@Param("hrSalary") HrSalary hrSalary);
}
